﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyOA.Model;
using System.Data.SqlClient;
using System.Data;

namespace MyOA.DAL
{
    public class MyOAService
    {
        DBHelper db = new DBHelper();

        /// <summary>
        /// 根据登陆帐号来获取此帐户的类别
        /// </summary>
        /// <param name="loginId">登陆帐号</param>
        /// <returns>返回用户类别信息</returns>
        public RoleInfo getRoleInfoByLoginId(string loginId)
        {
            RoleInfo roleInfo = new RoleInfo();
            //using (SqlDataReader reader=db.getDataReader("sp_getRoleInfoByLoginId",new SqlParameter("@loginId",loginId)))
            //{
            //    while (reader.Read())
            //    {
            //        roleInfo.RoleId = (int)reader[0];
            //        roleInfo.RoleName=(string)reader[1];
            //    }
            //}
            DataTable dt = db.getDataTable("sp_getRoleInfoByLoginId", new SqlParameter("@loginId", loginId));
            foreach (DataRow row in dt.Rows)
            {
                roleInfo.RoleId = (int)row[0];
                roleInfo.RoleName=(string)row[1];   
            }
            
            return roleInfo;
        }
    }
}
